﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using GameStudio.Common;
using GameStudio.CodeGeneration;

namespace GameStudio
{
    public class ProjectCreateInfo
    {
        public static string TmpLocation = "d:\\GS\\Templates";
        public static string DefaultProjectLocation = "d:\\GS";
        public string CurrentPath;
        public string ProjectName = "";
        public string ProjectType;

        //private ProjectFactory projectFactory;

        public ProjectCreateInfo()
        {
            
        }
        public ProjectCreateInfo(string location, string name, string type)
        {
            

            //CurrentPath = projectFactory.project.Location;
            //ProjectName = projectFactory.project.ProjectName;
            //this.projectFactory = projectFactory;
            ProjectType = type;

            CurrentPath = location;
            ProjectName = name;
        }

    
        public void CreateTemplate()
        {
            GenerateCode CG = new GenerateCode("class1", TmpLocation, ProjectName);
            CG.CreateCode();

            //GenerateObject generateObject = new GenerateObject("Object", TmpLocation, ProjectName);
            //generateObject.Generate("object");

            //GCPosition GenerateStruct = new GCPosition("Node", TmpLocation, ProjectName);
            //GenerateStruct.Generate("Node");

            GenerateEmptyClass EmptyClass=new GenerateEmptyClass("EmptyClass", TmpLocation, ProjectName);
            EmptyClass.Generate("Program");

            GenerateEmptyClass _MeshClass = new GenerateEmptyClass("_mesh", TmpLocation, ProjectName);
            _MeshClass.Generate("Mesh<Vertex>");
 
        }
        public void CreateProject()
        {
            if (ProjectType == "Empty Project")
            {
                CreateEmptyPrj();
            }
            if (ProjectType == "Class Library")
            {
                CreatwClassLib();
            }
                
        }

        private void CreatwClassLib()
        {
            // Create the subfolder
            System.IO.Directory.CreateDirectory(this.CurrentPath);

            //copy tmplte
            string sourceFile = System.IO.Path.Combine(ProjectCreateInfo.TmpLocation, "class1.cs");
            string destFile = System.IO.Path.Combine(this.CurrentPath, "class1.cs");
            // To copy a file to another location and 
            // overwrite the destination file if it already exists.
            System.IO.File.Copy(sourceFile, destFile, true);

            //FileItem file = new FileItem("class1.cs");
            //this.projectFactory.AddFile(file);
        }

        private void CreateEmptyPrj()
        {
            // Create the subfolder
            System.IO.Directory.CreateDirectory(this.CurrentPath);
            
        }
    }
}
